package com.ag.zrt.action;

import javax.annotation.Resource;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.common.AgException;
import com.ag.common.BaseAction;
import com.ag.zrt.service.ICurrentEventService;

@Controller("currentEventAction")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class CurrentEventAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5960803054469504829L;

	@Resource(name = "ZRTCurrentEventService")
	private ICurrentEventService currentEventService;

	private String eventId;
	private String currentStepId;
	private int updateSucc;

	public void setCurrentEventService(ICurrentEventService currentEventService) {
		this.currentEventService = currentEventService;
	}

	public int getUpdateSucc() {
		return updateSucc;
	}

	public String getCurrentStepId() {
		return currentStepId;
	}

	public void setCurrentStepId(String currentStepId) {
		this.currentStepId = currentStepId;
	}

	public String getEventId() {
		return eventId;
	}

	public void setEventId(String eventId) {
		this.eventId = eventId;
	}

	/*
	 * 更新当前步骤的序号
	 */
	public String updateCurrentStepNumAndCurrentStepId() {
		try {
			// TbCurrentEvent ce = currentEventService.findById(eventId);
			updateSucc = currentEventService.updateCurrentStepNum(eventId,
					currentStepId);
			System.out.println("-----------------updateSucc-----------------"
					+ updateSucc);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "updateCurrentStepNumAndCurrentStepId_succ";

	}

	/*
	 * 更新当前步骤的ID
	 */
	public String updateCurrentStepId() {

		try {
			currentEventService.updateCurrentStepId(eventId, currentStepId);
		} catch (AgException e) {
			e.printStackTrace();
			throw e;
		}

		return "updateCurrentStepId_succ";

	}

}
